package org.oos.atom.impl;

import java.util.ArrayList;
import java.util.List;

import org.oos.atom.AtomEntity;
import org.oos.atom.CategoryFeed;
import org.oos.atom.entries.impl.CategoryEntryImpl;

import com.google.api.client.util.Key;

/**
 * 
 * This class is used to parse the document returned by
 * "http://11870.com/api/v1/categories"
 * 
 * @author pablo.gonzalez@11870.com
 * 
 */
public class CategoryFeedImpl extends OOSFeedAdapter<CategoryEntryImpl>
		implements AtomEntity, CategoryFeed<CategoryEntryImpl> {

	private static final long serialVersionUID = 6779839282184129619L;

	@Key("atom:category")
	private List<CategoryEntryImpl> categories;

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.oos.atom.CategoryFeed#getCategories()
	 */
	public List<CategoryEntryImpl> getCategories() {
		if (categories == null) {
			return new ArrayList<CategoryEntryImpl>();
		} else {
			return categories;
		}
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.oos.atom.OOSFeedAdapter#getEntries()
	 */
	@Override
	public List<CategoryEntryImpl> getEntries() {
		return getCategories();
	}

}
